package work.lrl.coupon_inventory.code_to_json;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.text.StrBuilder;
import cn.hutool.json.JSONArray;
import com.alibaba.excel.EasyExcel;
import work.lrl.coupon_inventory.Setting;

import java.nio.charset.Charset;

import static work.lrl.coupon_inventory.Setting.*;

public class Main {
    public static void main(String[] args) {
        JSONArray jsonArray = new JSONArray();
        Setting.InventoryExcelReadListener listener = new Setting.InventoryExcelReadListener(
                (excelObject, analysisContext) -> {
                    jsonArray.add(excelObject.getCode());
                },
                analysisContext ->
                        FileUtil.writeString(jsonArray.toString(), codeJsonPath, Charset.defaultCharset())
        );
        EasyExcel.read(dataPath, Setting.InventoryExcelObject.class, listener).sheet("Sheet1").doRead();
    }
}
